<!DOCTYPE html>
<html>
<head>
  <title>DeviseDemo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <%= csrf_meta_tags %>
  <%= csp_meta_tag %>
  <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
  <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>

  <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.3/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.slim.min.js"></script>
  <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.3/js/bootstrap.bundle.min.js"></script>

</head>

<body>
<div class="container">
  <header class="blog-header py-3">
    <div class="row flex-nowrap justify-content-between align-items-center">
      <div class="col-3 pt-1">
        <%= link_to "博客列表", blogs_path, class: 'text-muted' %>
        <%= link_to "访问记录列表", access_logs_path, class: 'text-muted' %>
      </div>
      <div class="col-3 text-center">

      </div>
      <div class="col-6 d-flex justify-content-end align-items-center">
        <% if user_signed_in? %>
          <div class="btn-group">
            <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              <%= current_user.email %>
            </button>
            <div class="dropdown-menu">
              <%= link_to "我的博客", me_blogs_blogs_path, class: 'dropdown-item' %>
              <%= link_to "我的访问记录", me_access_log_access_logs_path, class: 'dropdown-item' %>
              <%= link_to "创建博客", new_blog_path, class: 'dropdown-item' %>
              <%= link_to "编辑用户", edit_user_registration_path, class: 'dropdown-item' %>
              <div class="dropdown-divider"></div>
              <%= link_to '退出登录', destroy_user_session_path, class: 'dropdown-item', method: 'delete' %>
            </div>
          </div>
        <% else %>
          <%= button_to "登录", new_user_session_path, class: 'btn btn-sm btn-outline-primary' %>
        <% end -%>
      </div>
    </div>
  </header>
  <% if notice != nil %>
    <div class="alert alert-primary" role="alert">
      <%= notice %>
    </div>
  <% end -%>
  <% if alert != nil %>
    <div class="alert alert-danger" role="alert">
      <%= alert %>
    </div>
  <% end -%>

  <%= yield %>
</div>

</body>
</html>
